<script type="text/javascript">
	var testCtrl = [ '$scope','baseService',function(scope, baseService) {
      /**
	   * 数据初始化。
	   */
		if(!scope.data){
			scope.data={};
		}
        if(!scope.data.CustomerApplication){
             scope.data.CustomerApplication={};
		}
		
      // 初始化一个字段 
      debugger;
      if(!scope.data.CustomerApplication.applicatFullname){
        scope.data.CustomerApplication.applicatFullname="JS初始化";
      }
      
      //初始化一条子表数据（这不是唯一的方式）
      debugger;
	  if(!scope.data.CustomerApplication.CustomerRespondentList ||scope.data.CustomerApplication.biz_customer_respondentList.length==0){
          scope.data.CustomerApplication.CustomerRespondentList = [];
        // scope.initData.Demo.DemoSub 子表数据的副本。当然直接push一个{} 也可以。
        var subTempData = {};
        // subTempData.ms = "请开启控制台，或者查看表单源码，来查看我是如何初始化的";
        scope.data.CustomerApplication.CustomerRespondentList.push(subTempData);
      }
      //植入一个点击事件
      scope.testfn = function(){
          $.Dialog.alert(scope.data.CustomerApplication.applicatId);
      }
				}
			]</script>
<div ng-controller="testCtrl">
    <div>
        <table class="form-table">
            <tbody>
                <tr class="firstRow">
                    <th>
                        申请人姓名
                    </th>
                    <td>
                        <input type="text" class=" form-control" ng-model="data.CustomerApplication.applicatFullname" ab-basic-permission="permission.CustomerApplication.biz_customer_application.applicatFullname" desc="申请人姓名" ab-validate="{}"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        状态
                    </th>
                    <td>
                        <input type="text" class=" form-control" ng-model="data.CustomerApplication.state" ab-basic-permission="permission.CustomerApplication.biz_customer_application.state" desc="状态" ab-validate="{}"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        创建时间
                    </th>
                    <td>
                        <input class=" form-control" ng-model="data.CustomerApplication.createTime" ab-validate="{}" desc="创建时间" ab-basic-permission="permission.CustomerApplication.biz_customer_application.createTime" ab-date="yyyy-MM-dd HH:mm:ss"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        创建人ID
                    </th>
                    <td>
                        <input type="text" class=" form-control" ng-model="data.CustomerApplication.createBy" ab-basic-permission="permission.CustomerApplication.biz_customer_application.createBy" desc="创建人ID" ab-validate="{}"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        更新时间
                    </th>
                    <td>
                        <input class=" form-control" ng-model="data.CustomerApplication.updateTime" ab-validate="{}" desc="更新时间" ab-basic-permission="permission.CustomerApplication.biz_customer_application.updateTime" ab-date="yyyy-MM-dd HH:mm:ss"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        更新人ID
                    </th>
                    <td>
                        <input type="text" class=" form-control" ng-model="data.CustomerApplication.updateBy" ab-basic-permission="permission.CustomerApplication.biz_customer_application.updateBy" desc="更新人ID" ab-validate="{}"/>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div id="CustomerApplication-CustomerRespondent" table-key="CustomerRespondent" ab-show-permission="tablePermission.CustomerApplication.CustomerRespondent">
        <div class="ibox-title">
            <span class="title">被申请客户表</span><a href="javascript:void(0)" class="btn btn-primary btn-sm fa fa-plus" ng-model="data.CustomerApplication.CustomerRespondentList" ab-sub-add="initData.CustomerApplication.CustomerRespondent" ab-edit-permission="tablePermission.CustomerApplication.CustomerRespondent">添加</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a class="btn btn-primary fa-search" href="javascript:void(0)" ab-cust-dialog="getPublicCustomers" ng-model="data.CustomerApplication.CustomerRespondentList" param="{}" dialog-setting="{&quot;multiple&quot;:true}" value-name="customerName">从数据库选择一个子表对象的数据填充进来</a>
        </div>
        <div class="ibox-content" ng-repeat="CustomerRespondent in data.CustomerApplication.CustomerRespondentList track by $index">
            <a class="btn btn-danger btn-xs fa fa-delete pull-right" ng-click="ArrayTool.del($index,data.CustomerApplication.CustomerRespondentList)" ab-edit-permission="tablePermission.CustomerApplication.CustomerRespondent"> 移除</a>
            <table class="form-table">
                <tbody>
                    <tr class="firstRow">
                        <th>
                            客户名称
                        </th>
                        <td>
                            <input type="text" class=" form-control" ng-model="CustomerRespondent.customerName" ab-basic-permission="permission.CustomerApplication.CustomerRespondent.customerName" desc="客户名称" ab-validate="{}"/>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>